﻿@inherits AdminCompontentBase

<DefaultSheetDialog Value="Visible" ValueChanged=UpdateVisible Title="@T("Edit ThirdPartyIdp")">
    <MForm Model=ThirdPartyIdp EnableValidation EnableI18n>
        <AutoHeight Overflow>
            <HeaderContent>
                <div class="d-flex">
                    <div class="mx-auto text-center" style="width:212px;">
                        <UploadAvatar @bind-Value="ThirdPartyIdp.Icon" Avatar Size="80" WhenFileChangeUpload />
                    </div>
                </div>
            </HeaderContent>
            <AutoHeightContent>
                <DefaultTitle Class="mb-6">@T("BasicInformation")</DefaultTitle>
                <MRow Class="mb-6 mt-12">
                    <MCol>
                        <STextField @bind-Value="ThirdPartyIdpDetail.Name" Required Disabled Label="@T("Name")" />
                    </MCol>
                    <MCol>
                        <STextField @bind-Value="ThirdPartyIdp.DisplayName" Required Label="@T(nameof(ThirdPartyIdp.DisplayName))" />
                    </MCol>
                </MRow>
                <MRow Class="mb-6">
                    <MCol>
                        <STextField @bind-Value="ThirdPartyIdp.ClientId" Required Label="@T(nameof(ThirdPartyIdp.ClientId))" />
                    </MCol>
                    <MCol>
                        <STextField @bind-Value="ThirdPartyIdp.ClientSecret" Required Label="@T(nameof(ThirdPartyIdp.ClientSecret))" />
                    </MCol>
                </MRow>
                <MRow Class="mb-6">
                    <MCol>
                        <STextField @bind-Value="ThirdPartyIdp.CallbackPath" Required Label="@T("CallbackPath")" />                      
                    </MCol>
                    <MCol>
                        <SUrlTextField @bind-Value="ThirdPartyIdp.AuthorizationEndpoint" Required Label="@T("AuthorizationEndpoint")" />                 
                    </MCol>
                </MRow>
                <MRow Class="mb-6">
                    <MCol>
                        <SUrlTextField @bind-Value="ThirdPartyIdp.TokenEndpoint" Required Label="@T("TokenEndpoint")" /> 
                    </MCol>
                     <MCol>
                        <SUrlTextField @bind-Value="ThirdPartyIdp.UserInformationEndpoint" Required Label="@T("UserInformationEndpoint")" />                       
                    </MCol>
                </MRow>
                <DefaultTitle Class="mb-6">@T("Advanced configuration")</DefaultTitle>
                <MRow Class="mb-6">
                    <MCol>
                        <MapJsonKey @bind-Value="AdvancedConfig" />
                    </MCol>
                </MRow>
                <MRow Class="mb-6">
                    <MCol>
                        <MCheckbox @bind-Value="ThirdPartyIdp.MapAll" Label="@T("Map all JSON key")" TValue="bool"/>
                    </MCol>
                </MRow>             
            </AutoHeightContent>
            <FooterContent>
                <div class="d-flex mt-6">
                    <EnableSwitch @bind-Value="ThirdPartyIdp.Enabled" />
                    <MSpacer></MSpacer>
                    <SButton Medium OnClick="async () => await UpdateThirdPartyIdpAsync(context)">@T("Save")</SButton>
                </div>
            </FooterContent>
        </AutoHeight>
    </MForm>
</DefaultSheetDialog>